package com.example.client.controller;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.example.model.api.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.env.Environment;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.*;

import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;

/**
 * @author Daniel Garnier-Moiroux
 */
@Controller
@Slf4j
public class AuthorizationConsentController {

	@GetMapping("home")
	public String home(Model model) {

		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//		log.info("authentication - principal {} {}", authentication, principal);
//		model.addAttribute("name", principal.getAttribute("name"));
//		model.addAttribute("login", principal.getAttribute("login"));
////
		return "home";
	}


}
